package main

//go get -u github.com/tietang/dbx
import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/tietang/dbx"
	"time"
)

func main() {
	settingd := dbx.Settings{
		DriverName: "mysql",
		Protocol:   "3306",
		User:       "root",
		Password:   "123456",
		Database:   "xiaoqu",
		Host:       "127.0.0.1",
		Options: map[string]string{
			"charset":   "utf8",
			"parseTime": "true",
		},
		ConnMaxLifetime: 5 * time.Hour, //闲置连接的最大存活时间
		MaxOpenConns:    5,             //最大连接数
		MaxIdleConns:    2,             //保持连接的最大空闲连接数
		LoggingEnabled:  false,
	}
	db, err := dbx.Open(settingd)
	if err != nil {
		panic(err)
	}
	fmt.Println(db.Ping())
}
